package com.hns.can.report.web;

import com.hns.can.common.domain.GridPage;
import com.hns.can.common.web.BaseController;
import com.hns.can.report.entity.*;
import com.hns.can.report.service.QualityAnlsSummaryService;
import com.hns.can.report.vo.QualityAnlsSummaryParamVo;
import com.hns.can.report.vo.QualityIndexParamVo;
import com.hns.frame.mybatis.Pagination;
import com.hns.tool.export.ExportUtil;
import com.hns.tool.pub.DateTool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;

import java.net.URLEncoder;
import java.util.*;

/**
 * 质量分析汇总控制类
 *
 * @author:zhangzq
 * @email:
 * @version Revision 2.0.0
 */
@Controller
@RequestMapping("/qualityAnlsSummary")
public class QualityAnlsSummaryController extends BaseController {

    //导出车辆行为统计周报
    final private String[] tBsStatWeakBhvHeaderNames = new String[]{"企业名称","营运线路","行为类型","日期(周)","车台数","发生次数","环比(%)","同比(%)"};
    final private String[] tBsStatWeakBhvHeaderFields = new String[]{"corpName", "lineName", "bhvTypeName", "reportDate", "carCount", "occurCount", "dayOnDay","dayOnWeak"};

    //导出车辆能耗统计周报
    final private String[] tBsStatWeakEnerConsHeaderNames = new String[]{"公司名称","营运线路","日期(周)","车台数","差值能耗","叠加能耗","全流量能耗值","客户能耗值","线路平均能耗","能耗偏差", "百公里能耗","环比(%)","同比(%)"};
    final private String[] tBsStatWeakEnerConsHeaderFields = new String[]{"corpName", "lineName","reportDate","carCount", "maxRngEnerCons","sumRngEnerCons", "tyEnerCons","custEnerCons","lineAvgEnerCons","enerConsOffset","enerConsPMile", "dayOnDay", "dayOnWeak"};

    //导出车辆故障统计周报
    final private String[] tBsStatWeakMftHeaderNames = new String[]{"公司名称","营运线路","日期(周)","故障类型名称","车台数","发生次数","环比(%)","同比(%)"};
    final private String[] tBsStatWeakMftHeaderFields = new String[]{"corpName", "lineName","reportDate", "mftTypeName",  "carCount", "occurCount", "dayOnDay", "dayOnWeak"};

    //导出在线率统计周报
    final private String[] tBsStatWeakOnlineHeaderNames = new String[]{"公司名称","营运线路","日期(周)","车台数","在线率%","基准值%","环比(%)","同比(%)"};
    final private String[] tBsStatWeakOnlineHeaderFields = new String[]{"corpName", "lineName","reportDate", "carCount", "onlineRate","baseLineValue", "dayOnDay", "dayOnWeak"};

    //导出车辆里程统计周报
    final private String[] tBsStatWeakMileHeaderNames = new String[]{"公司名称","营运线路","日期(周)","车台数","差值里程","叠加里程","全流量里程值","客户里程值","线路平均里程","里程偏差","环比(%)","同比(%)"};
    final private String[] tBsStatWeakMileHeaderFields = new String[]{"corpName", "lineName","reportDate", "carCount", "maxRngMile","sumRngMile","tyMile","custMile","lineAvgMile","mileOffset", "dayOnDay", "dayOnWeak"};

    //导出车辆报站统计周报
    final private String[] tBsStatWeakStnHeaderNames = new String[]{"公司名称","营运线路","日期(周)","趟数","全部站数","执行站数","实际站数","无报站数量","是否包含上下行","报站率","环比(%)","同比(%)"};
    final private String[] tBsStatWeakStnHeaderFields = new String[]{"corpName", "lineName","reportDate", "ranksNum", "allStnNum","exeStnNum","realStnNum","nullStnNum","ifUpDn","rpStnRate", "dayOnDay", "dayOnWeak"};
    @Autowired
    private QualityAnlsSummaryService qualityAnlsSummaryService;

    /**
     * 分页查询车辆行为统计周报
     *
     * @param vo
     * @return
     * @throws Exception
     * @author:zhangzq
     * @email:
     */
    @RequestMapping("/searchTBsStatWeakBhvPage")
    @ResponseBody
    public Object searchTBsStatWeakBhvPage(QualityAnlsSummaryParamVo vo) throws Exception {
        Pagination page = qualityAnlsSummaryService.searchTBsStatWeakBhvPage(vo);
        GridPage grid = new GridPage(page);
        return this.getReturnResult(grid);
    }

    /**
     * 查询最近8周车辆行为统计周报
     *
     * @param vo
     * @return
     * @throws Exception
     * @author:zhangzq
     * @email:
     */
    @RequestMapping("/getLast8TBsStatWeakBhvList")
    @ResponseBody
    public Object getLast8TBsStatWeakBhvList(QualityAnlsSummaryParamVo vo)throws Exception {
        List<TBsStatWeakBhvEntity> list = qualityAnlsSummaryService.getLast8TBsStatWeakBhvList(vo);
        return this.getReturnResult(list);
    }

    /**
     * 导出车辆行为统计周报Pdf文件
     * @param vo
     * @param response
     * @throws Exception
     * @author:zhangzq
     * @email:
     */
    @RequestMapping("/exportTBsStatWeakBhvPdf")
    public void exportTBsStatWeakBhvPdf(QualityAnlsSummaryParamVo vo, HttpServletResponse response) throws Exception {
        List<TBsStatWeakBhvEntity> list = list = qualityAnlsSummaryService.searchTBsStatWeakBhvList(vo);
        ExportUtil.exportFiles(Arrays.asList(tBsStatWeakBhvHeaderNames), Arrays.asList(tBsStatWeakBhvHeaderFields), list, response, "pdf", URLEncoder.encode("车辆行为统计周报", "UTF-8")+DateTool.getCurrentSysDate("yyyyMMddHHmmss"), "车辆行为统计周报数据");
    }
    
    /**
     * 导出车辆行为统计周报Excel文件
     * @param vo
     * @param response
     * @throws Exception
     * @author:zhangzq
     * @email:
     */
    @RequestMapping("/exportTBsStatWeakBhvExcel")
    public void exportTBsStatWeakBhvExcel(QualityAnlsSummaryParamVo vo, HttpServletResponse response) throws Exception {
        List<TBsStatWeakBhvEntity> list = list = qualityAnlsSummaryService.searchTBsStatWeakBhvList(vo);
        ExportUtil.exportFiles(Arrays.asList(tBsStatWeakBhvHeaderNames), Arrays.asList(tBsStatWeakBhvHeaderFields), list, response, "excel", URLEncoder.encode("车辆行为统计周报", "UTF-8")+DateTool.getCurrentSysDate("yyyyMMddHHmmss"), "车辆行为统计周报数据");
    }

    /**
     * 分页查询车辆能耗统计周报
     *
     * @param vo
     * @return
     * @throws Exception
     * @author:zhangzq
     * @email:
     */
    @RequestMapping("/searchTBsStatWeakEnerConsPage")
    @ResponseBody
    public Object searchTBsStatWeakEnerConsPage(QualityAnlsSummaryParamVo vo) throws Exception {
        Pagination page = qualityAnlsSummaryService.searchTBsStatWeakEnerConsPage(vo);
        GridPage grid = new GridPage(page);
        return this.getReturnResult(grid);
    }

    /**
     * 导出车辆能耗统计周报Pdf文件
     * @param vo
     * @param response
     * @throws Exception
     * @author:zhangzq
     * @email:
     */
    @RequestMapping("/exportTBsStatWeakEnerConsPdf")
    public void exportTBsStatWeakEnerConsPdf(QualityAnlsSummaryParamVo vo, HttpServletResponse response) throws Exception {
        List<TBsStatWeakEnerConsEntity> list = list = qualityAnlsSummaryService.searchTBsStatWeakEnerConsList(vo);
        ExportUtil.exportFiles(Arrays.asList(tBsStatWeakEnerConsHeaderNames), Arrays.asList(tBsStatWeakEnerConsHeaderFields), list, response, "pdf", URLEncoder.encode("车辆能耗统计周报", "UTF-8")+DateTool.getCurrentSysDate("yyyyMMddHHmmss"), "车辆能耗统计周报数据");
    }
    
    /**
     * 导出车辆能耗统计周报Excel文件
     * @param vo
     * @param response
     * @throws Exception
     * @author:zhangzq
     * @email:
     */
    @RequestMapping("/exportTBsStatWeakEnerConsExcel")
    public void exportTBsStatWeakEnerConsExcel(QualityAnlsSummaryParamVo vo, HttpServletResponse response) throws Exception {
        List<TBsStatWeakEnerConsEntity> list = list = qualityAnlsSummaryService.searchTBsStatWeakEnerConsList(vo);
        ExportUtil.exportFiles(Arrays.asList(tBsStatWeakEnerConsHeaderNames), Arrays.asList(tBsStatWeakEnerConsHeaderFields), list, response, "excel", URLEncoder.encode("车辆能耗统计周报", "UTF-8")+DateTool.getCurrentSysDate("yyyyMMddHHmmss"), "车辆能耗统计周报数据");
    }

    /**
     * 分页查询车辆故障统计周报
     *
     * @param vo
     * @return
     * @throws Exception
     * @author:zhangzq
     * @email:
     */
    @RequestMapping("/searchTBsStatWeakMftPage")
    @ResponseBody
    public Object searchTBsStatWeakMftPage(QualityAnlsSummaryParamVo vo) throws Exception {
        Pagination page = qualityAnlsSummaryService.searchTBsStatWeakMftPage(vo);
        GridPage grid = new GridPage(page);
        return this.getReturnResult(grid);
    }

    /**
     * 查询最近8周车辆故障统计周报
     *
     * @param vo
     * @return
     * @throws Exception
     * @author:zhangzq
     * @email:
     */
    @RequestMapping("/getLast8TBsStatWeakMftList")
    @ResponseBody
    public Object getLast8TBsStatWeakMftList(QualityAnlsSummaryParamVo vo ) throws Exception {
        List<TBsStatWeakMftEntity> list = qualityAnlsSummaryService.getLast8TBsStatWeakMftList(vo);
        return this.getReturnResult(list);
    }

    /**
     * 导出车辆故障统计周报Pdf文件
     * @param vo
     * @param response
     * @throws Exception
     * @author:zhangzq
     * @email:
     */
    @RequestMapping("/exportTBsStatWeakMftPdf")
    public void exportTBsStatWeakMftPdf(QualityAnlsSummaryParamVo vo, HttpServletResponse response) throws Exception {
        List<TBsStatWeakMftEntity> list = list = qualityAnlsSummaryService.searchTBsStatWeakMftList(vo);
        ExportUtil.exportFiles(Arrays.asList(tBsStatWeakMftHeaderNames), Arrays.asList(tBsStatWeakMftHeaderFields), list, response, "pdf", URLEncoder.encode("车辆故障计周报", "UTF-8")+DateTool.getCurrentSysDate("yyyyMMddHHmmss"), "车辆故障统计周报数据");
    }
    
    /**
     * 导出车辆故障统计周报Excel文件
     * @param vo
     * @param response
     * @throws Exception
     * @author:zhangzq
     * @email:
     */
    @RequestMapping("/exportTBsStatWeakMftExcel")
    public void exportTBsStatWeakMftExcel(QualityAnlsSummaryParamVo vo, HttpServletResponse response) throws Exception {
        List<TBsStatWeakMftEntity> list = list = qualityAnlsSummaryService.searchTBsStatWeakMftList(vo);
        ExportUtil.exportFiles(Arrays.asList(tBsStatWeakMftHeaderNames), Arrays.asList(tBsStatWeakMftHeaderFields), list, response, "excel",URLEncoder.encode("车辆故障统计周报", "UTF-8")+DateTool.getCurrentSysDate("yyyyMMddHHmmss"), "车辆故障统计周报数据");
    }

    /**
     * 分页查询车辆里程统计周报
     *
     * @param vo
     * @return
     * @throws Exception
     * @author:zhangzq
     * @email:
     */
    @RequestMapping("/searchTBsStatWeakMilePage")
    @ResponseBody
    public Object searchTBsStatWeakMilePage(QualityAnlsSummaryParamVo vo) throws Exception {
        Pagination page = qualityAnlsSummaryService.searchTBsStatWeakMilePage(vo);
        GridPage grid = new GridPage(page);
        return this.getReturnResult(grid);
    }

    /**
     * 导出车辆里程统计周报Pdf文件
     * @param vo
     * @param response
     * @throws Exception
     * @author:zhangzq
     * @email:
     */
    @RequestMapping("/exportTBsStatWeakMilePdf")
    public void exportTBsStatWeakMilePdf(QualityAnlsSummaryParamVo vo, HttpServletResponse response) throws Exception {
        List<TBsStatWeakMileEntity> list = list = qualityAnlsSummaryService.searchTBsStatWeakMileList(vo);
        ExportUtil.exportFiles(Arrays.asList(tBsStatWeakMileHeaderNames), Arrays.asList(tBsStatWeakMileHeaderFields), list, response, "pdf", URLEncoder.encode("车辆里程统计周报", "UTF-8")+DateTool.getCurrentSysDate("yyyyMMddHHmmss"), "车辆里程统计周报数据");
    }
    
    /**
     * 导出车辆里程统计周报Excel文件
     * @param vo
     * @param response
     * @throws Exception
     * @author:zhangzq
     * @email:
     */
    @RequestMapping("/exportTBsStatWeakMileExcel")
    public void exportTBsStatWeakMileExcel(QualityAnlsSummaryParamVo vo, HttpServletResponse response) throws Exception {
        List<TBsStatWeakMileEntity> list = list = qualityAnlsSummaryService.searchTBsStatWeakMileList(vo);
        ExportUtil.exportFiles(Arrays.asList(tBsStatWeakMileHeaderNames), Arrays.asList(tBsStatWeakMileHeaderFields), list, response, "excel", URLEncoder.encode("车辆里程统计周报", "UTF-8")+DateTool.getCurrentSysDate("yyyyMMddHHmmss"), "车辆里程统计周报数据");
    }

    /**
     * 分页查询车辆在线率统计周报
     *
     * @param vo
     * @return
     * @throws Exception
     * @author:zhangzq
     * @email:
     */
    @RequestMapping("/searchTBsStatWeakOnlinePage")
    @ResponseBody
    public Object searchTBsStatWeakOnlinePage(QualityAnlsSummaryParamVo vo) throws Exception {
        Pagination page = qualityAnlsSummaryService.searchTBsStatWeakOnlinePage(vo);
        GridPage grid = new GridPage(page);
        return this.getReturnResult(grid);
    }

    /**
     * 查询最近8周车辆在线率统计周报
     *
     * @param vo
     * @return
     * @throws Exception
     * @author:zhangzq
     * @email:
     */
    @RequestMapping("/getLast8TBsStatWeakOnlineList")
    @ResponseBody
    public Object getLast8TBsStatWeakOnlineList(QualityAnlsSummaryParamVo vo ) throws Exception {
        List<TBsStatWeakOnlineEntity> list = qualityAnlsSummaryService.getLast8TBsStatWeakOnlineList(vo);
        return this.getReturnResult(list);
    }

    /**
     * 导出车辆在线率统计周报Pdf文件
     * @param vo
     * @param response
     * @throws Exception
     * @author:zhangzq
     * @email:
     */
    @RequestMapping("/exportTBsStatWeakOnlinePdf")
    public void exportTBsStatWeakOnlinePdf(QualityAnlsSummaryParamVo vo, HttpServletResponse response) throws Exception {
        List<TBsStatWeakOnlineEntity> list = list = qualityAnlsSummaryService.searchTBsStatWeakOnlineList(vo);
        ExportUtil.exportFiles(Arrays.asList(tBsStatWeakOnlineHeaderNames), Arrays.asList(tBsStatWeakOnlineHeaderFields), list, response, "pdf", URLEncoder.encode("车辆在线率统计周报", "UTF-8")+DateTool.getCurrentSysDate("yyyyMMddHHmmss"), "车辆在线率统计周报数据");
    }
    
    /**
     * 导出车辆在线率统计周报Excel文件
     * @param vo
     * @param response
     * @throws Exception
     * @author:zhangzq
     * @email:
     */
    @RequestMapping("/exportTBsStatWeakOnlineExcel")
    public void exportTBsStatWeakOnlineExcel(QualityAnlsSummaryParamVo vo, HttpServletResponse response) throws Exception {
        List<TBsStatWeakOnlineEntity> list = list = qualityAnlsSummaryService.searchTBsStatWeakOnlineList(vo);
        ExportUtil.exportFiles(Arrays.asList(tBsStatWeakOnlineHeaderNames), Arrays.asList(tBsStatWeakOnlineHeaderFields), list, response, "excel", URLEncoder.encode("车辆在线率统计周报", "UTF-8")+DateTool.getCurrentSysDate("yyyyMMddHHmmss"), "车辆在线率统计周报数据");
    }

    /**
     * 分页查询车辆报站统计周报
     * @param vo
     * @return
     * @throws Exception
     * @author:chenl
     * @email:
     */
    @RequestMapping("/searchTBsStatWeakStopPage")
    @ResponseBody
    public Object searchTBsStatWeakStopPage(QualityAnlsSummaryParamVo vo) throws Exception {
        Pagination page = qualityAnlsSummaryService.searchTBsStatWeakStopPage(vo);
        GridPage grid = new GridPage(page);
        return this.getReturnResult(grid);
    }

    /**
     * 导出车辆在线率统计周报Excel文件
     * @param vo
     * @param response
     * @throws Exception
     * @author:zhangzq
     * @email:
     */
    @RequestMapping("/exportTBsStatWeakStopExcel")
    public void exportTBsStatWeakStnExcel(QualityAnlsSummaryParamVo vo, HttpServletResponse response) throws Exception {
        List<TBsStatWeakStnEntity> list = list = qualityAnlsSummaryService.searchTBsStatWeakStnList(vo);
        ExportUtil.exportFiles(Arrays.asList(tBsStatWeakStnHeaderNames), Arrays.asList(tBsStatWeakStnHeaderFields), list, response, "excel", URLEncoder.encode("车辆报站统计周报", "UTF-8")+DateTool.getCurrentSysDate("yyyyMMddHHmmss"), "车辆报站统计周报数据");
    }

    /**
     * 导出车辆在线率统计周报Pdf文件
     * @param vo
     * @param response
     * @throws Exception
     * @author:zhangzq
     * @email:
     */
    @RequestMapping("/exportTBsStatWeakStopPdf")
    public void exportTBsStatWeakStnPdf(QualityAnlsSummaryParamVo vo, HttpServletResponse response) throws Exception {
        List<TBsStatWeakStnEntity> list = list = qualityAnlsSummaryService.searchTBsStatWeakStnList(vo);
        ExportUtil.exportFiles(Arrays.asList(tBsStatWeakStnHeaderNames), Arrays.asList(tBsStatWeakStnHeaderFields), list, response, "pdf", URLEncoder.encode("车辆报站统计周报", "UTF-8")+DateTool.getCurrentSysDate("yyyyMMddHHmmss"), "车辆报站统计周报数据");
    }
}
